﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JQueryForm.Models;

namespace JQueryForm.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View(new Person());
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(FormCollection formData)
        {
            if (Request.IsAjaxRequest())
            {
                return Json(new string[] { "Test Text!", "Test Text 2!" });    
            }
            else
            {
                return View(new Person());
            }
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
